<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <th:block th:include="common.html :: source"></th:block>
    <script type="text/javascript" src="/js/productDetail.js"></script>
</head>
<body>

<th:block th:include="common.html :: header"></th:block>
<th:block th:include="common.html :: category"></th:block>

<div class="i_bg">
    <div class="content mar_20">
        <div id="favoriteList"></div>
        <div class="l_list">
            <div class="list_c">
                <ul class="cate_list">
                    <li th:each="productList1:${productList}">
                        <div class="name">
                            <a th:href="'/product/detail/'+${productList1.id}" th:text="${productList1.name}"></a>
                        </div>
                        <div class="price">
                            <font>￥<span th:text="${productList1.price}"></span></font> &nbsp;
                        </div>
                        <div class="img">
                            <a th:href="'/product/detail/'+${productList1.id}">
                                <img th:src="${productList1.fileName}" width="185"
                                     height="155" />
                            </a>
                        </div>
                        <div class="carbg" >
                            <a href="javascript:void(0);" class="ss" >收藏</a>
                            <a href="javascript:void(0);" th:onclick="addCart1([[${productList1.id}]],[[${productList1.price}]],[[${session.user}]])" class="j_car" >加入购物车</a>
                        </div>
                    </li>
                </ul>
            </div>
        </div>
    </div>
</div>

<th:block th:include="common.html :: footer"></th:block>
<th:block th:include="common.html :: permit"></th:block>

</body>
<script>
    function addCart1(productId,price,user){
        var quantity = 1;
        if(user==null){
            alert("尚未登陆！请登陆后重试！");
            window.location.href = "/login.html"
        }else {alert("添加成功！");
        $.ajax({
            url:"/cart/save1/"+productId+"/"+price+"/"+quantity,
            type:"POST",
        })
        }
    }
</script>
</html>